package com.xyf.statistics.service.impl;

import com.seventh.common.pojo.R;
import com.xyf.statistics.mapper.OrderStatisticsMapper;
import com.xyf.statistics.pojo.entity.TbOrder;
import com.xyf.statistics.service.OrderStatisticsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class OrderStatisticsServiceImpl implements OrderStatisticsService {

    @Resource
    OrderStatisticsMapper mapper;


    @Override
    public R selectOrder(String ymonth) {
        List<TbOrder> list= mapper.selectOrder(ymonth);
        List<String> datax=new ArrayList<>();
        List<String> price=new ArrayList<>();
        for (TbOrder order:list){
            datax.add(String.valueOf(order.getEndTime()));
            price.add(String.valueOf(order.getTotalPrice()));
        }
        Map chardata=new HashMap();
        chardata.put("datax",datax);
        chardata.put("price",price);
        return R.ok().put("chardata",chardata);
    }
}
